#include <bits/stdc++.h>
using namespace std;

char buf[10000005];
int ppos, llen;

inline char gch()
{
    if (ppos == llen)
    {
        ppos = 0;
        llen = fread(buf, 1, 10000000, stdin);
    }
    if (ppos == llen) return -1;
    return buf[ppos++];
}

template < typename T >
inline void read(T &x)
{
    x = 0;
    bool flg = 0;
    char c;
    while ((c = gch()) < 48 || c > 57)
        if (c == '-') flg = 1;
    do
    {
        x = (x << 1) + (x << 3) + (c ^ 48);
    } while ((c = gch()) > 47 && c < 58);
    if (flg) x = -x;
}

const int N = 1e5 + 5;
int m, d[N], v[N], a[N], p[N], abc[N], s[N]/*, t[N]*/;
/*
vector < int > vec[N];

inline int lowbit(int x)
{
    return x & (-x);
}

inline void Upd(int x, int val)
{
    while (x <= m)
    {
        t[x] += val;
        x += lowbit(x);
    }
}

inline int Qry(int x)
{
    int ret = 0;
    while (x)
    {
        ret += t[x];
        x -= lowbit(x);
    }
    return ret;
}
*/
inline void Chkmax(int &x, int y)
{
    if (y > x) x = y;
}

int main()
{
    freopen("detect.in", "r", stdin);
    freopen("detect.out", "w", stdout);
    int T;
    read(T);
    while (T--)
    {
        int n, L, V, cnt = 0, ans = 0;
        read(n);
        read(m);
        read(L);
        read(V);
        for (int i = 1; i <= n; ++i)
        {
            read(d[i]);
            read(v[i]);
            read(a[i]);
        }
        for (int i = 1; i <= m; ++i)
            read(p[i]);
        for (int i = 1; i <= m; ++i)
            abc[i] = -1;
        for (int i = 1; i <= n; ++i)
            if (!a[i])
            {
                if (v[i] > V)
                {
                    int num = lower_bound(p + 1, p + m + 1, d[i]) - p;
                    if (num <= m)
                    {
                        ++cnt;
                        Chkmax(abc[m], num);
                    }
                }
            }
            else if (a[i] > 0)
            {
                if (v[i] > V)
                {
                    int num = lower_bound(p + 1, p + m + 1, d[i]) - p;
                    if (num <= m)
                    {
                        ++cnt;
                        Chkmax(abc[m], num);
                    }
                }
                else
                {
                    int num = lower_bound(p + 1, p + m + 1, d[i] + (V * V - v[i] * v[i]) / (2 * a[i]) + 1) - p;
                    if (num <= m)
                    {
                        ++cnt;
                        Chkmax(abc[m], num);
                    }
                }
            }
            else
            {
                if (v[i] > V)
                {
                    int tmp = v[i] * v[i] - V * V, pos = 0;
                    if (!(tmp % (2 * (-a[i])))) pos = d[i] + tmp / (2 * (-a[i])) - 1;
                    else pos = d[i] + tmp / (2 * (-a[i]));
                    if (pos >= d[i])
                    {
                        int lft = lower_bound(p + 1, p + m + 1, d[i]) - p;
                        if (lft <= m)
                        {
                            int rgh = upper_bound(p + 1, p + m + 1, pos) - p - 1;
                            if (rgh >= lft)
                            {
                                ++cnt;
                                Chkmax(abc[rgh], lft);
                            }
                        }
                    }
                }
            }
        for (int i = 1; i <= m; ++i)
            if (abc[i] != -1)
            {
                if (s[i - 1] > s[abc[i] - 1])
                {
                    // printf("%d %d %d %d\n", i, abc[i], s[i - 1], s[abc[i] - 1]);
                    ++ans;
                    s[i] = s[i - 1];
                }
                else s[i] = s[i - 1] + 1;
            }
            else
            {
                // printf("%d\n", i);
                ++ans;
                s[i] = s[i - 1];
            }
        printf("%d %d\n", cnt, ans);
    }
    return 0;
}
